#include "effect_basic.h"
#include "irenderer.h"
#include "ishader.h"

namespace gecko
{

Effect_Basic::Effect_Basic(IRenderer* renderer)
{
	m_Shader = renderer->CreateShader("effect_basic.fx", PH_NUM);

	if (m_Shader)
	{
		m_Shader->BindParameter(PH_WVP, "gWVP");
		m_Shader->BindParameter(PH_ALPHA_ENABLED, "gAlphaEnabled");
		m_Shader->BindParameter(PH_SRCALPHA, "gSrcAlpha");
		m_Shader->BindParameter(PH_DESTALPHA, "gDestAlpha");
	}
}

void Effect_Basic::SetupFromRenderContext( const RenderContext& renderContext )
{
	if (m_Shader)
	{
		m_Shader->SetMatrix(PH_WVP, renderContext.GetViewProjectionMatrix());
	}
}

void Effect_Basic::EnableAlpha( bool enable )
{
	if (m_Shader)
	{
		m_Shader->SetBool(PH_ALPHA_ENABLED, enable);
	}
}

void Effect_Basic::SetSrcAlpha( IRenderer::eBlendMode blendMode )
{
	if (m_Shader)
	{
		m_Shader->SetBlendMode(PH_SRCALPHA, blendMode);
	}
}

void Effect_Basic::SetDestAlpha( IRenderer::eBlendMode blendMode )
{
	if (m_Shader)
	{
		m_Shader->SetBlendMode(PH_DESTALPHA, blendMode);
	}
}

}